<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<body>
<!--<ol class="page-navigator" th:fragment="pageNav(pageInfo, prevText, nextText, prefix)">-->
<div style="text-align: center" th:fragment="pageNav(pageInfo, prevText, nextText, prefix)">

    <!-- 处理页数小于7 的情况     -->
    <ul class="pagination" data-th-if="${pageInfo.pages lt 7}">
        <!-- 上一页 -->
        <li class="page-item" data-th-classappend="${pageInfo.isFirstPage} ? 'disabled' : ''">
            <a th:if="${not pageInfo.isFirstPage}" class="page-link" aria-label="Previous" th:href="@{${'/user/page'}(pageNum=${pageInfo.pageNum-1},pageSize=${pageInfo.pageSize})}">«</a>
        </li>

        <!-- 迭代生成页码 -->
        <li class="page-item" data-th-each="i : ${#numbers.sequence(1, pageInfo.pages)}" data-th-classappend="${(pageInfo.pageNum) eq i} ? 'active' : ''" >
            <a th:if="${pageInfo.pageNum eq i}" href="javascript:void(0);">
                <span th:text="${i}"></span>
            </a>
            <a th:if="${not (pageInfo.pageNum eq i)}" th:href="@{${'/user/page'}(pageNum=${i},pageSize=${pageInfo.pageSize})}">
                <span th:text="${i}"></span>
            </a>
        </li>

        <!-- 下一页 -->
        <li class="page-item" data-th-classappend="${pageInfo.isLastPage} ? 'disabled' : ''">
            <a th:if="${not pageInfo.isLastPage}" th:href="@{${'/user/page'}(pageNum=${pageInfo.pageNum+1},pageSize=${pageInfo.pageSize})}">»</a>
        </li>
    </ul>

    <!-- 处理页数等于7 的情况     -->
    <ul class="pagination" data-th-if="${pageInfo.pages eq 7}">
        <!-- 上一页 -->
        <li class="page-item" data-th-classappend="${pageInfo.isFirstPage} ? 'disabled' : ''">
            <a th:if="${not pageInfo.isFirstPage}" class="page-link" aria-label="Previous" th:href="@{${'/user/page'}(pageNum=${pageInfo.pageNum-1},pageSize=${pageInfo.pageSize})}">«</a>
        </li>

        <!-- 迭代生成页码 -->
        <li class="page-item" data-th-each="i : ${#numbers.sequence(1, pageInfo.pages)}" data-th-classappend="${(pageInfo.pageNum) eq i} ? 'active' : ''" >
            <a th:if="${pageInfo.pageNum eq i}" href="javascript:void(0);">
                <span th:text="${i}"></span>
            </a>
            <a th:if="${not (pageInfo.pageNum eq i)}" th:href="@{${'/user/page'}(pageNum=${i},pageSize=${pageInfo.pageSize})}">
                <span th:text="${i}"></span>
            </a>
        </li>

        <!-- 下一页 -->
        <li class="page-item" data-th-classappend="${pageInfo.isLastPage} ? 'disabled' : ''">
            <a th:if="${not pageInfo.isLastPage}" th:href="@{${'/user/page'}(pageNum=${pageInfo.pageNum+1},pageSize=${pageInfo.pageSize})}">»</a>
        </li>
    </ul>



    <!-- 处理页数大于7 的情况     -->
    <ul class="pagination" data-th-if="${pageInfo.pages gt 7}" >
        <!--  上一页 -->
        <li class="page-item" data-th-classappend="${pageInfo.isFirstPage} ? 'disabled' : ''">
            <a th:if="${not pageInfo.isFirstPage}" class="page-link" aria-label="Previous" th:href="@{${'/user/page'}(pageNum=${pageInfo.pageNum-1},pageSize=${pageInfo.pageSize})}">«</a>
        </li>

        <!--  首页 -->
        <li class="page-item" data-th-classappend="${(pageInfo.pageNum) eq 1} ? 'active' : ''" >
            <a class="page-link" aria-label="Previous" th:href="@{${'/user/page'}(pageNum=1,pageSize=${pageInfo.pageSize})}">1</a>
        </li>


        <!--   当前页面小于等于4 -->
        <li class="page-item" data-th-if="${(pageInfo.pageNum) le 4}" data-th-each="i : ${#numbers.sequence(2,5)}"   data-th-classappend="${(pageInfo.pageNum) eq i} ? 'active' : ''" >
            <a th:href="@{${'/user/page'}(pageNum=${i},pageSize=${pageInfo.pageSize})}">
                <span th:text="${i}"></span>
            </a>
        </li>

        <li class="page-item disabled" data-th-if="${(pageInfo.pageNum) le 4}">
            <a href="javascript:void(0);" class="page-link">
                <span aria-hidden="true">...</span>
            </a>
        </li>

        <!--   最后一页与当前页面之差，小于等于3 -->
        <li class="page-item disabled" data-th-if="${(pageInfo.pages-(pageInfo.pageNum)) le 3}">
            <a href="javascript:void(0);" class="page-link">
                <span aria-hidden="true">...</span>
            </a>
        </li>
        <li class="page-item" data-th-if="${(pageInfo.pages-(pageInfo.pageNum)) le 3}" data-th-each="i : ${#numbers.sequence(pageInfo.pages-4, pageInfo.pages-1)}"
            data-th-classappend="${(pageInfo.pageNum) eq i} ? 'active' : ''" >
            <a th:href="@{${'/user/page'}(pageNum=${i},pageSize=${pageInfo.pageSize})}">
                <span th:text="${i}"></span>
            </a>
        </li>

        <!--   最后一页与当前页面之差大于3，且  当前页面大于4 -->

        <li class="page-item disabled" data-th-if="${((pageInfo.pageNum) gt 4) &amp;&amp; ((pageInfo.pages-(pageInfo.pageNum)) gt 3 )}">
            <a href="javascript:void(0);" class="page-link">
                <span aria-hidden="true">...</span>
            </a>
        </li>

        <li class="page-item" data-th-if="${((pageInfo.pageNum) gt 4) &amp;&amp; ((pageInfo.pages-(pageInfo.pageNum)) gt 3 )}">
            <a th:if="${not pageInfo.isFirstPage}" class="page-link" aria-label="Previous" th:href="@{${'/user/page'}(pageNum=${pageInfo.pageNum-1},pageSize=${pageInfo.pageSize})}"><span th:text="${pageInfo.pageNum-1}"></span></a>
        </li>

        <li class="page-item active" data-th-if="${((pageInfo.pageNum) gt 4) &amp;&amp; ((pageInfo.pages-(pageInfo.pageNum)) gt 3 )}" >
            <a th:if="${not pageInfo.isFirstPage}" class="page-link" th:href="@{${'/user/page'}(pageNum=${pageInfo.pageNum},pageSize=${pageInfo.pageSize})}"><span th:text="${pageInfo.pageNum}"></span></a>
        </li>

        <li class="page-item" data-th-if="${((pageInfo.pageNum) gt 4) &amp;&amp; ((pageInfo.pages-(pageInfo.pageNum)) gt 3 )}">
            <a th:if="${not pageInfo.isFirstPage}" class="page-link" aria-label="Previous" th:href="@{${'/user/page'}(pageNum=${pageInfo.pageNum+1},pageSize=${pageInfo.pageSize})}"><span th:text="${pageInfo.pageNum+1}"></span></a>
        </li>

        <li class="page-item disabled"  data-th-if="${((pageInfo.pageNum) gt 4) &amp;&amp; ((pageInfo.pages-(pageInfo.pageNum)) gt 3 )}">
            <a href="javascript:void(0);" class="page-link">
                <span aria-hidden="true">...</span>
            </a>
        </li>

        <!--   最后一页 -->
        <li class="page-item" data-th-classappend="${(pageInfo.pageNum) eq pageInfo.pages} ? 'active' : ''" >
            <a th:href="@{${'/user/page'}(pageNum=${pageInfo.pages},pageSize=${pageInfo.pageSize})}"><span th:text="${pageInfo.pages}"></span></a>
        </li>

        <!--   下一页 -->
        <li class="page-item" data-th-classappend="${pageInfo.isLastPage} ? 'disabled' : ''">
            <a th:if="${not pageInfo.isLastPage}" th:href="@{${'/user/page'}(pageNum=${pageInfo.pageNum+1},pageSize=${pageInfo.pageSize})}">»</a>
        </li>
        <span class="label label-default" th:text="${pageInfo.pages}">New</span>

        一共<span class="btn btn-default" th:text="${pageInfo.pages}"></span>页
    </ul>

</div>

<div th:fragment="pageAdminNav(pageInfo)">
    <div class="clearfix">
        <ul class="pagination m-b-5 pull-right">
            <li th:if="${pageInfo.hasPreviousPage}">
                <a th:href="@{'?page='+${pageInfo.prePage}}" aria-label="Previous">
                    <i class="fa fa-angle-left"></i>&nbsp;上一页
                </a>
            </li>

            <th:block th:each="nav : ${pageInfo.navigatepageNums}">
                <li th:class="${nav==pageInfo.pageNum}?'active':''"><a th:href="@{'?page='+${nav}}" th:text="${nav}"></a>
                </li>
            </th:block>

            <th:block th:if="${pageInfo.hasNextPage}">
                <li>
                    <a th:href="@{'?page='+${pageInfo.nextPage}}" aria-label="Next">
                        下一页&nbsp;<i class="fa fa-angle-right"></i>
                    </a>
                </li>
            </th:block>

            <li><span th:text="'共'+${pageInfo.pages}+'页'"></span></li>
        </ul>
    </div>
</div>

</body>
</html>